<div class="cont">
    <div class="position " id="page_title"><img alt="位置图标" src="dist/images/position.png" />风控合规>邮寄管理 <a ng-click="openDetail()" ng-hide="$needClientCache" title="打开新窗口查看"><i class="large External icon"></i></a></div>
    <div class="mybackground">
        <div class="ui top attached tabular menu">
            <a ng-click="DeliveryList(1,matter_state)" id="default" class="item {{defaultcss}}">合同邮寄记录</a>
            <a ng-click="DeliveryList(2,matter_state)" id="invoice" class="item {{invoice}}">发票邮寄记录</a>
            <a ng-click="DeliveryList(3,matter_state)" id="refund" class="item {{refund}}">退款协议记录</a>
        </div>
        <div class="cont_fr_top">
            <div class="menus_top">
                <div class="menus_l">处理状态：</div>
                <ul id="nav">
                    <li class="{{selected6}}" id="remove_css"><a ng-click="state(6)">全部</a></li>
                    <li class="{{selected10}}" id="add_css"><a ng-click="state(10)"> 待邮寄   </a></li>
                    <li class="{{selected20}}" id="confirm_css"><a ng-click="state(20)"> 确认邮寄 </a></li>
                    <li class="{{selected30}}"><a ng-click="state(30)"> 邮寄中   </a></li>
                    <li class="{{selected40}}"><a ng-click="state(40)"> 邮寄完成 </a></li>
                    <li class="{{selected50}}"><a ng-click="state(50)"> 取消邮寄 </a></li>
                </ul>
                <div class="cont_fr_btn">
                    <div style="height: 20px;">
                        <div class="fr">
                            <a ng-hide="hide_but3" ng-click="export_delivery(exportDefault)" style="margin-right:5px;">下载标准模板</a>
                            <button class="cont_f_btn3" ng-hide="hide_but3" ngf-select="import_delivery($file)" ngf-pattern="'.xls,.xlsx'" ngf-accept="'.xls,.xlsx'" ngf-max-size="20MB"><i class="ui download icon"></i>导入</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="menus">
                <div class="menus_con ui form" ng-keyup="$event.keyCode == 13 && DeliveryList(sessions,matter_state)">
                    <div class="four fields">
                        <div class="inline field">
                            <label>客户姓名</label>
                            <input type="text" ng-model="search.customer" placeholder="客户姓名" maxlength="15" style="width: 160px">
                        </div>
                        <div class="inline field">
                            <label>快递订单号</label>
                            <input type="text" ng-model="search.order_num" placeholder="快递订单号" style="width:160px">
                        </div>
                        <div class="inline field">
                            <label>创建时间</label>
                            <div class="ui left icon input">
                                <input type="text" name="first_time" id="first_time" datetimepicker format='YYYY-MM-DD' ng-model="search.first_time" placeholder="开始时间" style="width:160px">
                                <i class="calendar icon"></i>
                            </div>
                        </div>
                        <div class="inline field">
                            <label>结束时间</label>
                            <div class="ui left icon input">
                                <input type="text" name="second_time" id="second_time" datetimepicker format='YYYY-MM-DD' ng-model="search.second_time" placeholder="结束时间" style="width:160px">
                                <i class="calendar icon"></i>
                            </div>
                        </div>
                    </div>
                    <div class="four fields">
                        <div class="inline field">
                            <label>业务人员</label>
                            <input type="text" ng-model='search.sales' placeholder="服务人员" style="width: 160px">
                        </div>
                    </div>
                    <div class=" fields">
                        <div class="inline field">
                            <button class="clear_btn" ng-click="DeliveryList(sessions,matter_state)" style="margin-left: 4.8em;"> 查找</button>
                        </div>
                        <div class="inline field">
                            <button class="clear_btn" ng-hide="hide_but2" ng-click="export_delivery()"> <i class="ui upload icon"></i>导出</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="menus_table">
        <table class="ui yellow celled striped table">
            <thead>
                <tr>
                    <th> 客户 </th>
                    <th> 快递订单号 </th>
                    <th> 快递运单号 </th>
                    <th> 创建时间 </th>
                    <th> 邮寄时间 </th>
                    <th> 收件人姓名 </th>
                    <th> 收件人地址 </th>
                    <th> 收件人电话 </th>
              <!--       <th> 服务人员 </th>
                    <th> 所属经理 </th>
                    <th> 所属团队 </th> -->
                    <th> 邮寄状态 </th>
                    <th style="text-align:center;width:198px" > 操作 </th>
                </tr>
            </thead>
            <tbody ng-hide="exist">
                <tr ng-repeat="vlist in unit.list">
                    <td> <!-- {{ vlist.customer_name }} --> 
                        <div float_layer customer-id='vlist.customer_id' show-name="vlist.nickname"></div>
                    </td>
                    <td> {{ vlist.order_num }} </td>
                    <td> {{ vlist.delivery_num }} </td>
                    <td> {{ vlist.create_time }} </td>
                    <td> {{ vlist.send_time }} </td>
                    <td> {{ vlist.recipients }} </td>
                    <td class="ellipsis" ng-attr-title="{{ vlist.address }}"> {{ vlist.address }} </td>
                    <td> {{ vlist.phone }} </td>
              <!--       <td> {{ vlist.user_name }} </td>
                    <td> {{ vlist.manager }} </td>
                    <td> {{ vlist.sector_name }} </td> -->
                    <td>
                        <div ng-switch="vlist.status">
                            <div ng-switch-when="10">待邮寄</div>
                            <div ng-switch-when="20">已确认邮寄</div>
                            <div ng-switch-when="30">邮寄中</div>
                            <div ng-switch-when="40">邮寄已完成</div>
                            <div ng-switch-when="50">已取消</div>
                        </div>
                    </td>
                    <td style="text-align:center">
                        <a ng-click="EditorShow(slist.fine_id,1)" ng-if="vlist.source_type == 1 && vlist.status < 30" style="width:20px;height:20px"> 编辑 </a>
                        <a ng-if="vlist.status == 10 && vlist.source_type != 3" ng-click="second_confirm(vlist.delivery_id)" style="width:20px;height:20px"> 确认 </a>
                        <a ng-click="cancel_show(vlist.delivery_id)" ng-if="vlist.status == 10  && vlist.source_type != 3" style="width:20px;height:20px"> 取消 </a>
                        <a ng-click="completeShow(vlist.delivery_id)" ng-if="vlist.status == 30 " style="width:20px;height:20px"> 邮寄完成 </a>
                        <a ng-click="showContractDetail(vlist.contract_id)" ng-if="vlist.source_type == 1 " style="width:20px;height:20px">对应合同</a>
                    </td>
                </tr>
            </tbody>
            <tbody ng-hide="empty">
                <tr>
                    <td colspan="10" style="text-align:center;margin-top:10px" class="null_data">没有找到数据~~~</td>
                </tr>
            </tbody>
        </table>
        <div ng-show="DeliveryPage.pageAll > 1" class="ui borderless fr pagination menu" jspagination ng-model="sessions_matter" page-object="DeliveryPage" page-func="DeliveryList">
        </div>
    </div>
</div>
<!--批量操作-->
<div class="ui confirm large modal">
    <i class="close icon"></i>
    <div class="header_h4"> 编辑确认邮寄 </div>
    <div class="content">
        <div class="menus_table" style="overflow: auto;">
            <table class="ui celled striped table">
                <thead>
                    <tr>
                        <th> 复选框 </th>
                        <th> 客户 </th>
                        <th> 邮寄时间 </th>
                        <th> 收件人姓名 </th>
                        <th> 收件人地址 </th>
                        <th> 收件人电话 </th>
                        <th> 服务人员 </th>
                        <th> 所属经理 </th>
                        <th> 所属团队 </th>
                        <th> 邮寄状态 </th>
                    </tr>
                </thead>
                <tbody ng-hide="exist">
                    <tr ng-repeat="vlist in confirmList">
                        <td style="text-align:center">
                            <input type="checkbox" class="check_list" name="checkbox" value="{{vlist.delivery_id}}" checked="checked" />
                        </td>
                        <td> {{ vlist.customer_name }} </td>
                        <td> {{ vlist.send_time }} </td>
                        <td> {{ vlist.recipients }} </td>
                        <td> {{ vlist.address }} </td>
                        <td> {{ vlist.phone }} </td>
                        <td> {{ vlist.user_name }} </td>
                        <td> {{ vlist.manager }} </td>
                        <td> {{ vlist.sector_name }} </td>
                        <td>
                            <div ng-switch="vlist.status">
                                <div ng-switch-when="10">待邮寄</div>
                                <div ng-switch-when="20">已确认邮寄</div>
                                <div ng-switch-when="30">邮寄中</div>
                                <div ng-switch-when="40">邮寄已完成</div>
                                <div ng-switch-when="50">已取消</div>
                            </div>
                        </td>
                    </tr>
                </tbody>
                <tbody ng-hide="empty">
                    <tr>
                        <td colspan="10" style="text-align:center;margin-top:10px" class="null_data">没有找到数据~~~</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button">确定</div>
        <div class="ui grey  negative button">{{'BTN_CANCEL' | translate}}</div>
        </di>
    </div>
</div>
<!--合同详情-->
<ng-include src="'views/header.html'" ng-if="contractDetails == 1" class="ui row" style="display:none"></ng-include>
<!--合同邮寄编辑-->
<div class="ui EditorShow large modal">
    <i class="close icon"></i>
    <div class="header_h4"> 合同邮寄编辑 </div>
    <div class="content">
        <div class="ui form">
            <form name="frm-contract-mail" id="frm-contract-mail">
                <input type="hidden" name="delivery_id" id="deliveryId">
                <input type="hidden" name="contract_id" id="contractId">
                <div class="ui segment">
                    <div><b>客户信息</b></div>
                    <div class="ui segment">
                        <div class="four fields">
                            <div class="field">
                                <span>客户姓名 :  </span> {{ initial.customer_name }}
                            </div>
                            <div class="field">
                                <span>客户电话 : </span> {{ initial.phone }}
                            </div>
                            <div class="field">
                                <span>业务人员 : </span> {{ initial.user_name }}
                            </div>
                            <div class="field">
                                <span>团队 : </span> {{ initial.sector_name }}
                            </div>
                        </div>
                        <div class="four fields">
                            <div class="field">
                                <span>订购产品 : </span> {{ initial.name }}
                            </div>
                            <div class="field">
                                <span>金额(元) : </span> {{ initial.contract_mount }}
                            </div>
                            <div class="field">
                                <span>开始时间 : </span> {{ initial.start_time }}
                            </div>
                            <div class="field">
                                <span>结束时间 : </span> {{ initial.end_time }}
                            </div>
                        </div>
                        <div class="four fields">
                            <div class="field">
                                <span class="fl" style="margin-right: 3px;">合同状态 : </span>
                                <div ng-switch="initial.state" style="float:left">
                                    <div ng-switch-when="-1"> 已取消 </div>
                                    <div ng-switch-when="1"> 待审核 </div>
                                    <div ng-switch-when="2"> 升级作废 </div>
                                    <div ng-switch-when="3"> 已完成 </div>
                                    <div ng-switch-when="4"> 签订中 </div>
                                    <div ng-switch-default> 正常用户 </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div><b>客户信息</b></div>
                <div class="three fields">
                    <div class=" field required">
                        <label class="label_fl">收件人姓名</label>
                        <input type="text" name="recipients" ng-model='initial.recipients' placeholder="收件人姓名" style="width:160px;height:32px">
                    </div>
                    <div class="field required">
                        <label class="label_fl">收件人地址</label>
                        <input type="text" name="address" ng-model='initial.address' placeholder="收件人地址" style="width:160px;height:32px;margin-left:0.5em">
                    </div>
                    <div class="field required">
                        <label class="label_fl">收件人电话</label>
                        <input type="text" name="phone" ng-model='tel' maxlength="15" placeholder="收件人电话" style="width:160px;height:32px">
                    </div>
                </div>
                <div class="three fields ">
                    <div class=" field required" id="sendTime">
                        <label class="label_fl">创建时间</label>
                        <div class="ui left icon input " style="width:160px;margin-left:0.9em">
                            <input datetimepicker id="send_time" name="send_time" format='YYYY-MM-DD' ng-model="initial.create_time" ng-change="check_time()" placeholder=" 创建时间 " style="width: 160px;height: 32px">
                            <i class="calendar icon"></i>
                        </div>
                        <div class="ui red pointing prompt label " ng-hide="verify_time" ng-class='{error:isError}'>创建时间不能为空!!!</div>
                    </div>
                    <div class="inline field">
                        <label>合同签订状态</label>
                        <div class="ui selection dropdown" id="initialId" style="height:32px;">
                            <input type="hidden" name="sign_status" ng-model="initial.sign_status">
                            <i class="dropdown icon"></i>
                            <div class="default text">合同签订状态</div>
                            <div class="menu">
                                <div class="item" data-value="{{v.k}}" ng-repeat="v in sign_status">{{v.v}}</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="fields">
                    <div class="inline field">
                        <label>备注信息</label>
                        <input type="text" name="remark" ng-model="initial.delivery_remrk" placeholder="备注信息" style="margin-left:1.4em;width: 890px;height:32px">
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button">确定</div>
        <div class="ui grey button negative">取消</div>
    </div>
</div>
<!--邮寄完成操作弹窗-->
<div class="ui complete small modal">
    <i class="close icon"></i>
    <div class="header_h4"> 合同邮寄完成 </div>
    <div class="content">
        <div class="ui form">
            <form name="frm-complete" id="frm-complete">
                <div class="field" style="text-align: center"> 请输入邮寄运单号 </div>
                <div class="field" style="height:80px">
                    <input type="hidden" id="isExist" name="isExist">
                    <input name="delivery_num" ng-model='complete.delivery_num' ng-keyup="checkNum()" ng-blur="checkNum()" >
                </div>
            </form>
        </div>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button">确定</div>
        <div class="ui grey button negative">取消</div>
    </div>
</div>
<!--上传失败弹窗-->
<div class="ui error_shw modal transition">
    <div class="header_h4">系统提示</div>
    <div class="content">
        <table class="ui celled striped table">
            <thead>
                <tr>
                    <th>标题</th>
                    <th colspan="2">提示信息</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> 上传数据共 <span style="color:red"> ( {{ statistics.sum }} )        </span> 条</td>
                    <td> 更新成功共 <span style="color:red"> ( {{ statistics.successful }} ) </span> 条</td>
                    <td> 重复数据共 <span style="color:red"> ( {{ statistics.repeat }} )     </span> 条</td>
                </tr>
                <tr>
                    <td> 更新失败共 <span style="color:red"> ( {{ statistics.failures }} )   </span> 条</td>
                    <td colspan="2"> <span style="text-align: center;color:red"> {{ failure }} </span> </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button" ng-click="DeliveryList(sessions_matter,matter_state)">关闭</div>
    </div>
</div>
<!-- 取消違規确认-->
<div class="ui cancel_show modal">
    <i class="close icon"></i>
    <div class="header_h4">取消邮寄记录</div>
    <div class="content" style="text-align: center;">
        <p>确认取消该条邮寄记录吗？</p>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button" ng-click="cancel(cancelId)">确定</div>
        <div class="ui grey button negative">取消</div>
    </div>
</div>
<!--二次确认-->
<div class="ui second_confirm modal">
    <i class="close icon"></i>
    <div class="header_h4">确认邮寄记录</div>
    <div class="content" style="text-align: center;">
        <p>确认邮寄该条邮寄记录吗？</p>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button" ng-click="affirm(secondId)">确定</div>
        <div class="ui grey button negative">取消</div>
    </div>
</div>
<!--成功-->
<div class="ui small modal modal3 time" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge green check circle outline icon"></i>
        <p style="padding-top: 15px;">{{Msg}}成功</p>
    </div>
</div>
<!--失败-->
<div class="ui modal modal2 time" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge red warning outline icon"></i>
        <p style="padding-top: 15px;">{{Msg}}失败</p>
    </div>
</div>

<script type="text/javascript">
    $(function() {
        $.fn.form.settings.rules.checkNum = function() {
            var isValid = true;
            var isExist = $('#frm-complete input[name="isExist"]').val();
            if(isExist == 1)
                isValid = false;
            else 
                isValid = true;
        return isValid;
    };
    var myurl = "go('/" + location.hash.split('/')[1] + "')";
    $(".go_item").each(function() {
        if ($(this).attr('ng-click') == myurl) {
            $('.cont_fl .title').removeClass('active');
            $('.cont_fl .content').removeClass('active');
            $(this).closest('.content').addClass('active');
            $(this).closest('.menu').removeClass('hidden').addClass('visible');
            $(this).closest('.content').prev().addClass('active');
            $(".go_item").removeClass("active");
            $(this).addClass('active');
        }
    });
    $('.example .ui.dropdown')
        .dropdown({
            allowAdditions: true
        });
    $("#nav li").click(function() {
        $(this).addClass('selected').siblings().removeClass('selected');
    });
    $(".ui.top a").click(function() {
        $(this).addClass('active').siblings().removeClass('active');
    });
    $('#frm-complete').form({
        on: 'blur',
        inline: true,
        fields: {
            delivery_num: {
                rules: [{
                    type: 'empty',
                    prompt: '运单号不能空!!!'
                },{
                    type   : 'checkNum',
                    prompt : '此运单号已存在!!!'
                },{
                    type   : 'minLength[5]',
                    prompt : '运单号不能小于5位字符'
                  }
                ]
            }
        }
    });
    $('#frm-contract-mail').form({
        on: 'blur',
        inline: true,
        fields: {
            recipients: {
                rules: [{
                    type: 'empty',
                    prompt: '收件人不能空!'
                }]
            },
            order_num: {
                rules: [{
                    type: 'empty',
                    prompt: '快递编号不能空!'
                }]
            },
            send_way: {
                rules: [{
                    type: 'empty',
                    prompt: '运单编号不能空!'
                }]
            },
            reach_time: {
                rules: [{
                    type: 'empty',
                    prompt: '到达时间不能空!'
                }]
            },
            address: {
                rules: [{
                    type: 'empty',
                    prompt: '邮寄地址不能空!'
                }]
            },
            phone: {
                rules: [{
                    type: 'empty',
                    prompt: '收件人电话不能空!'
                }, {
                    type: 'integer[1..]',
                    prompt: '号码格式不正确!'
                }, {
                    type: 'minLength[7]',
                    prompt: '收件人电话至少7位有效数字!'
                }]
            },
            main_content: {
                rules: [{
                    type: 'empty',
                    prompt: '邮寄内容不能空!'
                }]
            },
            status: {
                rules: [{
                    type: 'empty',
                    prompt: '邮寄状态不能空!'
                }]
            },
        }
    });
});
</script>
